//
//  BaseViewController.m
//  TestDemo
//
//  Created by zhangwenqiao on 2018/12/4.
//  Copyright © 2018年 zhangwenqiao. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self typeOne];
//    [self typeTwo];
    
//    [self.navigationController setNavigationBarHidden:NO animated:YES];
//    self.navigationController.navigationBarHidden = NO;
}

//既修改文字也修改图片，不影响返回的手势问题。
- (void)typeOne {
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:nil];
    [self.navigationController.navigationBar setBackIndicatorImage:[[UIImage imageNamed:@"timg.jpeg"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [self.navigationController.navigationBar setBackIndicatorTransitionMaskImage:[[UIImage imageNamed:@"timg.jpeg"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    self.navigationController.navigationBar.tintColor = [UIColor darkGrayColor];
}

//这个只是修改返回按钮的文字显示，设置为空字符串，就不显示文字，这个不会影响作画返回的手势
- (void)typeTwo {
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc]initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
    self.navigationItem.backBarButtonItem = backItem;
//    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:nil];
    self.navigationController.navigationBar.tintColor = [UIColor darkGrayColor];
}

//这种方式会造成左滑手势失效的情况，所以设置按钮的目标动作回调。
- (void)typeThree {
    UIBarButtonItem * buttonItem = [[UIBarButtonItem alloc]initWithTitle:@"啊啊" style:UIBarButtonItemStyleDone target:self action:@selector(tapLeftButton:)];
    [buttonItem setImage:[UIImage imageNamed:@"back"]];
    self.navigationItem.leftBarButtonItem= buttonItem;
}

- (void)tapLeftButton:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
